package com.lling.oscbugly;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import java.util.ArrayList;
import java.util.List;


public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.demo_032).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                test032();
            }
        });
        findViewById(R.id.demo_035).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                test035();
            }
        });
    }

//    032. java.util.ConcurrentModificationException
//    java.util.ConcurrentModificationException
//    java.util.ArrayList$ArrayListIterator.next(ArrayList.java:569)
//            com.android.system.report.ReportSDK$2.run(ReportSDK.java:215)
//            java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
//            java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
//            java.lang.Thread.run(Thread.java:838)
    private void test032() {
        List<String> list = new ArrayList<String>();
        list.add("a");
        list.add("b");
        list.add("c");
        list.add("d");
        for (String str : list) {
            if(str.equals("c")){
                list.remove(str);
            }else{
                Log.d("TAG", str);
            }
        }
    }

//    java.lang.UnsatisfiedLinkError
//    java.lang.RuntimeException:An+error+occured+while+executing+doInBackground()
//    android.os.AsyncTask$3.done(AsyncTask.java:299)
//            ......
//    cause+by:
//    java.lang.UnsatisfiedLinkError:Native+method+not+found:+com.umeng.update.util.DeltaUpdate.bspatch:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I
//    com.umeng.update.util.DeltaUpdate.bspatch(Native+Method)
//            com.umeng.update.util.DeltaUpdate.a(DeltaUpdate.java:30)
//            com.umeng.update.net.c$c.a(DownloadTool.java:715)
//            com.umeng.update.net.c$c.doInBackground(DownloadTool.java:688)
//            android.os.AsyncTask$2.call(AsyncTask.java:287)
//            java.util.concurrent.FutureTask.run(FutureTask.java:234)
//            android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
//            java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
//            java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
//            java.lang.Thread.run(Thread.java:841)
    private void test035() {
        new DemoTask().execute();
    }

    class DemoTask extends AsyncTask<Object, Object, Object> {
        @Override
        protected Object doInBackground(Object... params) {

            int a = Test.bspatch("a", "b", "c");
            Log.e("TAG", "result:" + a );
            return null;
        }

        @Override
        protected void onPostExecute(Object o) {
            super.onPostExecute(o);
        }
    }


}
